package cn.study.luckyinfrastructure.gateway.iml;

import cm.study.config.util.AssertUtil;
import cn.study.luckydomain.acceptPrize.AcceptPrizeEntity;
import cn.study.luckydomain.gateway.IAcceptPrizeGateWay;
import cn.study.luckyinfrastructure.convertor.AcceptPrizeConvertor;
import cn.study.luckyinfrastructure.gateway.iml.dataObject.AcceptPrizeDB;
import cn.study.luckyinfrastructure.gateway.iml.mapper.AcceptPrizeMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@AllArgsConstructor
public class AcceptPrizeGateWayImpl implements IAcceptPrizeGateWay {
    private final AcceptPrizeMapper acceptPrizeMapper;
    @Override
    public AcceptPrizeEntity add(AcceptPrizeEntity acceptPrizeEntity) {
        AcceptPrizeDB acceptPrizeDB = AcceptPrizeConvertor.toAcceptPrizeDB(acceptPrizeEntity);
        int insert = acceptPrizeMapper.insert(acceptPrizeDB);
        AssertUtil.isTrue(insert<=0,"插入失败");
        return AcceptPrizeConvertor.toEntity(acceptPrizeDB);
    }
}
